/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2012 Regents of the University of California
 */

#include <asm.h>
#include <csr.h>

#define KERNEL_STACK		0x50500000

.data 
debug: .string "debug...\n\r"

.equ bios_func_entry, 0x50150000

.section ".entry_function","ax"
ENTRY(_start)
  /* Mask all interrupts */
  csrw CSR_SIE, zero
  csrw CSR_SIP, zero


  /* TODO: [p1-task2] clear BSS for flat non-ELF images */
  la  a1, __bss_start
  la  a2, __BSS_END__
  bgt a1, a2, Bss_Clear_Done

Bss_Clear:
  sb   zero, 0(a1)
  addi a1,   a1, 1
  ble  a1,   a2, Bss_Clear

Bss_Clear_Done:


  /* TODO: [p1-task2] setup C environment */
  lui  sp,     %hi(KERNEL_STACK)
  addi sp, sp, %lo(KERNEL_STACK)
 
  //jump to main 
  call main

loop:
  wfi
  j loop

END(_start)
